
from google.appengine.api import urlfetch
from google.appengine.ext import webapp
from google.appengine.api import users
from google.appengine.ext.webapp import template
from google.appengine.ext import db
from google.appengine.ext.webapp import util

# project imports
from config import appsettings
from servlets.base_handler import BaseHandler
from model.blogpost import BlogPost
from servlets.write import WriteHandler

class MainHandler(BaseHandler):
  template = "main.html"
  def get(self):
    self.template_vars['blogPosts'] = db.GqlQuery("SELECT * FROM BlogPost ORDER BY date DESC")
    self.fill_template()


app = webapp.WSGIApplication([
    ('/', MainHandler),
    ('/write', WriteHandler)
  ], debug=True)

if __name__ == '__main__':
    webapp.util.run_wsgi_app(app)
